package com.study.mall.design.cal;

import org.junit.jupiter.api.Test;

public class CalDemo {
    @Test
    public void test1() {
        Cal cal = CalFactory.createCal(1);
        cal.getResult();
        cal = CalFactory.createCal(2);
        cal.getResult();

        cal = CalFactory.createCal2("sub");
    }


    public static void main(String[] args) {
        //变量、对象、实例、引用
        Add add = new Add(3, 5);
        int result1 = add.getResult();
        System.out.println(result1);

        //Person person = new Student();
        Cal cal = new Add(3, 5);
        int result2 = cal.getResult();
        System.out.println(result2);
        cal = new Sub(3, 5);
        int result3 = cal.getResult();
        System.out.println(result3);

        //'Cal' is abstract; cannot be instantiated
        //Cal cal1 = new Cal();
    }

    public void jiSuan(Cal cal) {
        //Cal cal = new Add(3, 5);
        cal.getResult();
    }

    public void jiSuan(Add add) {
        add.getResult();
    }

    public void jiSuan(Sub sub) {
        sub.getResult();
    }

    public void jiSuan(Mul mul) {
        mul.getResult();
    }
}
